package main;
import java.io.Serializable;
import java.util.*;

import enums.RationLevel;
import enums.TravelPace;

/**
 * The Class Menu which determines what happens when a certain menu choice is selected
 */
public class Menu implements Serializable {
	
	private static final long serialVersionUID = 3377414942304946183L;
	private final int FARMER_MONEY = 200;
	private final int CARPENTER_MONEY = 300;
	private final int BANKER_MONEY = 500;
	
	private int panelSave;
	/** The worldstate. */
	private WorldState worldstate;

	/**
	 * Instantiates a new menu.
	 */
	public Menu() {
		panelSave = 1;
		this.worldstate = new WorldState();
	}
	
	public int getPanelSave() {
		return panelSave;
	}
	
	public void setPanelSave(int panel) {
		this.panelSave = panel;
	}
	
	/**
	 * Getter for the worldState
	 * @return worldState
	 */
	public WorldState getWorldstate() {
		return worldstate;
	}

	/**
	 * Start up menu.
	 *
	 * @param playerName the player name
	 * @param partyNames the party names
	 * @param prof the profession
	 * @param pace the travel pace
	 * @param ration the ration level
	 */
	public void startUpMenu(String playerName, List<String> partyNames,
			Profession prof, TravelPace pace, RationLevel ration) {
		double money;
		Pioneer[] pioneers = new Pioneer[5];
		pioneers[0] = new Pioneer(playerName, prof);
		
		if (prof == Profession.CARPENTER) {
			money = CARPENTER_MONEY;
		} else if (prof == Profession.BANKER) {
			money = BANKER_MONEY;
		} else {      //if Profession.FARMER
			money = FARMER_MONEY;
		}
		
		for (int i = 1; i < 5; i++) {
			pioneers[i] = new Pioneer(partyNames.get(i - 1), Profession.NONE);
		}
		TravelGroup travelGroup = new TravelGroup(pioneers, ration, pace, money,
				new Inventory(0,0,0,0,0,0));
		worldstate = new WorldState(2, 12, travelGroup);
	}

	/**
	 * Update display.
	 */
	public String updateDisplay() {
		Inventory pack = worldstate.getTravelGroup().getPack();
		return ("Here are the supplies in your wagon now:\n\n"+
				"Number of Oxen: "+pack.getQtyOxen()+"\n"+
				"Amount of Food: "+pack.getQtyFood()+"\n"+
				"Amount of Clothing: "+pack.getQtyClothes()+"\n"+
				"Number of Wagon Wheels: "+pack.getQtyWagonWheel()+"\n"+
				"Number of Wagon Axles: "+pack.getQtyWagonAxle()+"\n"+
				"Number of Wagon Tongues: "+pack.getQtyWagonTongue()+"\n\n"+
				"Now that you have bought some supplies, we can head off!");
	}

	/**
	 * Trail menu.
	 */
	public void trailMenu() {

	}

	/**
	 * Fort menu.
	 */
	public void fortMenu() {

	}

	/**
	 * Store menu.
	 */
	public void storeMenu() {

	}

	/**
	 * River menu.
	 */
	public void riverMenu() {

	}

	/**
	 * Win game menu.
	 */
	public void winGameMenu() {

	}

	/**
	 * Lose game menu.
	 */
	public void loseGameMenu() {

	}

	/**
	 * Game save.
	 */
	public void gameSave() {

	}

	/**
	 * Game load.
	 */
	public void gameLoad() {

	}

	/**
	 * Tells world state to get the TravelGroup's toString.
	 * 
	 * @return the worldState's travel group's toString
	 */
	public String getTravelGroupString() {
		return "Welcome to the Oregon Trail!\n" +
				"Today is "+worldstate.getDate()+"!\n"+
				worldstate.getTravelGroup().toString();
	}

}

